<?php

/*
 *    Document   : core
 *   Created on : Jun 11, 2011, 3:51:07 PM
 *    Author     : ClarkT AKA FalleN
 *    Company    : Amodity
 *    Web        : http://www.amodity.com
 *    Copyright  : 2011
 */

class Core extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->load->library('auth');
        $this->_prev_url();
        $this->load->helper('config_file');
    }

    function _prev_url() {
//set previous url
        if (isset($_SERVER['HTTP_REFERER'])) {
            $this->session->set_userdata('prev_url', $_SERVER['HTTP_REFERER']);
        } else {
            $this->session->set_userdata('prev_url', base_url());
        }
    }

//--------------------------------------------------------------------

    function _is_logged_in() {
        if (!$this->auth->logged_in()) {
            redirect('admin/login');
        }
    }

//--------------------------------------------------------------------

    function _is_admin() {
        if (!$this->auth->is_admin()) {
            $this->message->set('error', lang('admin_no_admin'));
            redirect('admin/login');
        }
    }

//--------------------------------------------------------------------
}

?>